import {
  MenuFoldOutlined,
  MenuUnfoldOutlined,
  UploadOutlined,
  UserOutlined,
  VideoCameraOutlined,
} from '@ant-design/icons';

import { FormattedMessage } from "react-intl"

import Dashboard from "@/pages/dashboard/index"
import GoodList from "@/pages/good/goodList"
import GoodForm from "@/pages/good/goodForm"
import User from "@/pages/user/index"

import Layout from "@/pages/layout/index.jsx";
import Login from "@/pages/login/index.jsx";

export const constantRoutes = [
  { path: "/", element: <Layout />, children: [] },
  { path: "/login", element: <Login />, children: [] },
]


// asyncRoutes 动态路由
// 根据后端响应的角色，计算出该角色可以访问哪些动态路由
export const asyncRoutes = [
  {
    key: 1001,
    path: "/dashboard",
    label: <FormattedMessage id='menu.dashboard' />,
    icon: <MenuFoldOutlined />,
    element: <Dashboard />,
    meta: {
      roles: ["admin", "editor"]
    }
  },
  {
    key: 1002,
    icon: <VideoCameraOutlined />,
    label: <FormattedMessage id='menu.good' />,
    meta: {
      roles: ["editor","admin"]
    },
    children: [
      {
        key: 100201,
        path: "/good/list",
        icon: null,
        label: <FormattedMessage id='menu.good.list' />,
        element: <GoodList />
      },
      {
        key: 100202,
        path: "/good/add",
        icon: null,
        label: <FormattedMessage id='menu.good.add' />,
        element: <GoodForm />,
        hidden: true
      },
      {
        key: 100203,
        path: "/good/edit",
        icon: null,
        label: <FormattedMessage id='menu.good.edit' />,
        element: <GoodForm />,
        hidden: true
      }
    ]
  },
  {
    key: 1003,
    path: "/user",
    element: <User />,
    icon: <UserOutlined />,
    label: <FormattedMessage id='menu.user' />,
    meta: {
      roles: ["admin"]
    }
  }
]